//
//  DBJAddIllCaseFourCell.m
//  DBJ
//
//  Created by Captain_czq on 16/11/14.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "DBJAddIllCaseFourCell.h"
#import <HMImagePickerController.h>
@interface DBJAddIllCaseFourCell ()<HMImagePickerControllerDelegate>

@property (strong, nonatomic) IBOutletCollection(UIImageView) NSArray *iconVIews;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *addBtnLead;

@property(nonatomic,weak)UIButton *btn;
/* 取消btn数组 */
@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *cancelBtn;

@end

@implementation DBJAddIllCaseFourCell


- (IBAction)addPhoto:(UIButton *)sender {
    self.btn=sender;
   if([self.delegate respondsToSelector:@selector(FourCellAddphotoWithCell:)]){
       [self.delegate FourCellAddphotoWithCell:self];
   }
}

#pragma mark -重写setimageIconViews方法
/* setImageIConViews方法*/
-(void)setIconImagesViews:(NSMutableArray *)iconImagesViews{
    
    _iconImagesViews=iconImagesViews;
    
    for(NSUInteger i=0;i<iconImagesViews.count;i++){
        UIImageView *icon=self.iconVIews[i];
        icon.image=iconImagesViews[i];
    }
    CGFloat width=8+114.0;
    self.addBtnLead.constant=8+(iconImagesViews.count*width);
    for(int i=0;i<self.iconImagesViews.count;i++){
        UIButton *fir=self.cancelBtn[i];
        fir.hidden=NO;
    }
  
    if(iconImagesViews.count==3){
        self.btn.hidden=YES;
    }
}

- (IBAction)CancelBtn:(UIButton *)sender {
    //点击一次删除最后的图片对象
    [self.iconImagesViews removeLastObject];
    //设置视图
    for(NSUInteger i=0;i<self.iconImagesViews.count;i++){
        
        UIImageView *icon=self.iconVIews[i];
        icon.image=_iconImagesViews[i];
    }
    UIImageView *icon=self.iconVIews[self.iconImagesViews.count];
    icon.image=nil;
    
    CGFloat width=8+114.0;
    self.addBtnLead.constant=8+(self.iconImagesViews.count*width);
    self.btn.hidden=NO;
    sender.hidden=YES;
    
    UIButton *btn=self.cancelBtn[0];
    if(btn.isHidden){
        
        self.btn.hidden=NO;
    }

}



@end
